package com.leet.code.lcof;

public class Code21 {
    public static void main(String[] args) {

//        int[] nums = new int[]{1};
        int[] nums = new int[]{1, 2, 3, 4, 5};

        for (int i : new Code21().exchange(nums)) {
            System.out.println(i);
        }

    }


    public int[] exchange(int[] nums) {


        int start = 0;
        int end = nums.length - 1;
        int tmp;
        while (start < end) {

            if ((nums[start] & 1) == 0) {

                while (start < end && ((nums[end] & 1) == 0)) {
                    end--;
                }
                tmp = nums[start];
                nums[start] = nums[end];
                nums[end] = tmp;

            }
            start++;

        }

        return nums;

    }

}
